<?php if (!defined('THINK_PATH')) exit();?><!--添加栏目-->
<div class="dialog_content" style="max-height: 350px; overflow-y: auto;">
	<form id="info_form" action="<?php echo U('exam/add');?>" method="post">
		<input type="hidden" name="id" value="<?php echo ($info["id"]); ?>">
		<table width="100%" class="table_form" id="table_form">
			<tr><td>
				标题：
				<textarea name="name" style="width: 400px" id="name" cols="40" rows="3" class="form-control input-text"><?php echo ($info["name"]); ?></textarea>
			</td></tr>
			<tr><td>
				分值：<input class="form-control input-text" style="width: 60px;" name="score" value="<?php echo ($info["score"]); ?>">
			</td></tr>
			<tr><td>类型：
				<select name="type" class="form-control input-text" id="exam_add_type">
					<option value="radio">单选</option>
					<option value="checkbox">多选</option>
				</select>
			</td></tr>
			<tr><td>选项：（顺序依次为ABCDEFG...,不填写的那个答案不生效）添加：<input type="button" class="btn btn-default addFiled" value="添加"></td></tr>
			<tr><td style="color: #ff0000;font-weight: bold;">如果是正确答案，请在前面打钩</td></tr>
			<?php if(empty($info["content"])): ?><tr class="answer"><td>
					<select name="key[]" class="form-control input-text"><option value="false">非答案</option><option value="true">答案</option></select><input class="form-control input-text" style="width: 300px;margin-left: 30px;" name="value[]">
				</td></tr>
				<?php else: ?>
				<?php if(is_array($info["content"])): foreach($info["content"] as $key_chh=>$vo): ?><tr class="answer"><td>
						<select name="key[]" class="form-control input-text" id="child_answer_<?php echo ($key_chh); ?>"><option value="false">非答案</option><option value="true">答案</option></select><input class="form-control input-text" style="width: 300px;margin-left: 30px;" name="value[]" value="<?php echo ($vo); ?>">
					</td></tr><?php endforeach; endif; endif; ?>

		</table>
	</form>
</div>
<?php if(is_array($info["answer"])): foreach($info["answer"] as $key_chh=>$vo): ?><script type="text/javascript">
		$('#child_answer_<?php echo ($key_chh); ?>').val("true");
	</script><?php endforeach; endif; ?>
<?php if(!empty($info)): ?><script type="text/javascript">
		$('#exam_add_type').val("<?php echo ($info['type']); ?>");
	</script><?php endif; ?>
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	$('#info_form').ajaxForm({success:complate,dataType:'json'});
	function complate(result){
		if(result.errNum === 0){
			$.dialog.get('add_exam').close();
			$.yhxia.tip({content:result.retData});
			window.location.reload();
		} else {
			$.yhxia.tip({content:result.errMsg, icon:'alert'});
		}
	}
});
$('.addFiled').click(function () {
	var temp='<tr class="answer"><td><select name="key[]" class="form-control input-text"><option value="false">非答案</option><option value="true">答案</option></select><input class="form-control input-text" style="width: 300px;margin-left: 30px;" name="value[]"></td></tr>';
	$('#table_form').append(temp);
});
</script>